package net.xiduth.game.player.dialogues;

import net.xiduth.cache.loaders.NPCDefinitions;
import net.xiduth.game.player.Skills;

/**
 * 
 * @author Plato
 * 
 */

public class ArmourSalesman extends Dialogue {

	public static int SKILLCAPE = 9757;
	public static int SKILLHOOD = 9758;

	private int npcId;

	@Override
	public void start() {
		npcId = (Integer) parameters[0];
		sendEntityDialogue(SEND_2_TEXT_CHAT,
				new String[] {
						NPCDefinitions.getNPCDefinitions(npcId).name,
						"Hello " + player.getUsername()
								+ ", would you like to "
								+ "buy a Skillcape of Ranged?" }, IS_NPC,
				npcId, 9827);
		stage = -1;
	}

	@Override
	public void run(int interfaceId, int componentId) {
		if (stage == -1) {
			sendOptionsDialogue("Select a Option", "Yes please!", "No thanks!");
		}

		if (componentId == OPTION_1) {
			if (player.getSkills().getLevelForXp(Skills.RANGE) < 99) {
				player.getInterfaceManager().closeChatBoxInterface();
				player.getPackets()
						.sendGameMessage(
								"You need atleast level 99 in Ranged to purchase this cape.");
				return;
			}

			if (player.getInventory().containsItem(995, 99000)) {
				player.getInventory().deleteItem(995, 99000);
				player.getInventory().addItem(SKILLHOOD, 1);
				player.getInventory().addItem(SKILLCAPE, 1);
				player.getInterfaceManager().closeChatBoxInterface();
			} else {
				player.getInterfaceManager().closeChatBoxInterface();
				player.getPackets().sendGameMessage(
						"You need atleast 99,000 coins to purchase this cape.");
			}

		}
		if (componentId == OPTION_2) {
			player.getInterfaceManager().closeChatBoxInterface();
		}

	}

	@Override
	public void finish() {

	}

}
